<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增第三方接口')" />
    
    <style type="text/css">
    label {
	   margin-right: 10px
	}
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-url-add" th:object="${thirdShort}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">名称：</label>
                <div class="col-sm-8">
                    <input th:field="*{name}" id="name" name="name" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">api地址：</label>
                <div class="col-sm-8">
                    <input th:field="*{api}" id="api" name="api" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">请求方式：</label>
                <div class="col-sm-8">
                    <select th:field="*{method}" id="method" name="method" class="form-control">
                        <option value="get">get</option>
                        <option value="post">post</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">api参数：</label>
                <div class="col-sm-8">
                    <input th:field="*{param}" id="param" name="param" class="form-control" type="text" placeholder="参数格式为param1=xxx&param2=XX"><br>
                    可以使用  <font color="red">{url}</font>  来指代目标地址
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">参数是否进行url编码：</label>
                <div class="col-sm-8">
                    <label><input th:field="*{urlencode}" name="urlencode" class="form-control" type="radio" value="1">是</label>
                    <label><input th:field="*{urlencode}" name="urlencode" class="form-control" type="radio" value="0">否</label>
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label">结果解析：</label>
                <div class="col-sm-8">
                    <input th:field="*{parsekey}" id="parsekey" name="parsekey" class="form-control" type="text" placeholder="如果结果是json，需要配置此项用来找到结果值"><br>
                    注意，只有当结果是json格式的时候才需要配置，例如返回值{"url":"http://rrd.me/baidu","error":""}，那么这里应该填写为<font color="red">url</font>
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">排序：</label>
                <div class="col-sm-8">
                    <input th:field="*{sort}" id="sort" name="sort" class="form-control" type="number" value="1" required>
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否作为默认项：</label>
                <div class="col-sm-8">
                    <label><input th:field="*{useDefault}" name="useDefault" class="form-control" type="radio" value="1">是</label>
                    <label><input th:field="*{useDefault}" name="useDefault" class="form-control" type="radio" value="0">否</label>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否显示：</label>
                <div class="col-sm-8">
                    <label><input th:field="*{visable}" name="visable" class="form-control" type="radio" value="1">是</label>
                    <label><input th:field="*{visable}" name="visable" class="form-control" type="radio" value="0">否</label>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "short/third"
        $("#form-url-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-url-add').serialize());
            }
        }
    </script>
</body>
</html>